$(function(){

});

//设置性别
function setSex(obj) {
	var param = {
		id:$(obj).attr("dataId"),
		sex:$(obj).val()
	};
	API.elementSetSex(param, function(res) {
		if(res.code == 0) {
            window.location.reload();

        } else {
			alert(res.desc);
			window.location.reload();

		}
	});
}

//设置年龄
function setAge(obj) {
	var param = {
		id:$(obj).attr("dataId"),
		age:$(obj).val(),
		flag:$(obj).prop("checked")
	};
	API.elementSetAge(param, function(res) {
		if(res.code == 0) {
            window.location.reload();
        } else {
			alert(res.desc);
            window.location.reload();
        }
	});
}

function submitSexAge(obj) {
	if(UTIL.checkButton(obj)) {
		var ids = '';

		$("select[name='sex']").each(function() {
			ids += $(this).attr("dataId") + ",";
		});
		var param = {
			"ids" : ids
		};
		API.elementSubmitSexAge(param, function(res) {
			if(res.code == 0) {
				window.location.reload();
				$(window).scrollTop(0);
			} else {
				alert(res.desc);
			}
			UTIL.releaseButton(obj);
		});
	}
}

function exportSexAge(obj) {
	if(UTIL.checkButton(obj)) {
		window.location.href="/vocab/element_export_sex_age.htm";
		UTIL.releaseButton(obj);
	}
}

function initSexAge(obj) {
    if(UTIL.checkButton(obj)) {
        API.elementInitSynSexAge(function (res) {
            if (res.code == 0) {
				alert("成功");
                window.location.reload();
            } else {
                alert(res.desc);
            }
            UTIL.releaseButton(obj);
        });
    }
}